package com.example.naodian.controller;


import com.example.naodian.domain.dto.RecordingDto;
import com.example.naodian.domain.vo.EegRecordingVO;
import com.example.naodian.result.Result;
import com.example.naodian.service.IEegRecordingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author icewx
 * @since 2025-04-10
 */
@RestController
@RequestMapping("/eeg-recording")
@Api(tags = "脑袋记录信息相关接口")
@Slf4j
@AllArgsConstructor
@CrossOrigin(origins = "*") // 允许所有域名跨域请求
public class EegRecordingController {
    private final IEegRecordingService eegRecordingService;

    /**
     * 多条件查询记录信息
     * @param id 记录id
     * @param userId 用户id
     * @param recordingName 记录名称
     * @return EegRecordingVO集合
     */
    @ApiOperation("多条件查询脑电记录信息")
    @GetMapping("/list")
    public Result<List<EegRecordingVO>> getEegRecordingInfo(Long id,
                                            Long userId, String recordingName){
        log.info("记录id:{},用户id:{},记录名称:{}",id,userId,recordingName);
        return Result.success(eegRecordingService.getEegRecordingInfo(id,userId,recordingName));
    }

    /**
     * 新增记录信息
     * @param recordingDto
     * @return
     */
    @ApiOperation("新增脑电记录")
    @PostMapping
    public Result<Long> add(@RequestBody RecordingDto recordingDto){
        log.info("记录信息:{}",recordingDto);
        //返回新增记录的id
        Long id = eegRecordingService.add(recordingDto);
        return Result.success(id);
    }
}
